<template>
    <view style="display: flex; flex-direction: column; height: 100vh;background-color: #fff;">
		
		<xmInfo
		    :projectno="itemContent.projectno"
		    :projectname="itemContent.projectname"
		  ></xmInfo>
		  <view style="flex: 1;  overflow: scroll;padding: 10px;">
			  <view v-if="list.length" v-for="(item,index) in list" :key="index" @click="jmp(item)" style="display: flex;align-items: center;padding: 10px;background-color: #fff;">
			  	<u-icon name="/static/image/folder.png" :size="80"></u-icon>
				<text class="text-xl" style="margin-left: 20px;"> {{item.name}}</text>
			  </view>
			<u-empty v-if="!list.length"></u-empty>
		</view>
		<js-lang v-if="title" :title="title"></js-lang>
    </view>
</template>
<script>
import xmInfo from "@/pages/zfgs/index/componetns/xmInfo.vue";
  export default{
  components: {xmInfo },
    data(){
        return{
			title:'',
			triggered: false,
			loadStatus: 'loadmore',
			query: {
				pageNo: 1,
				pageSize: 20,
			},
			itemContent:{},
            imgList: ["http://192.168.1.49:8080/app/static/image/zfgs/zfgs1.jpg","http://192.168.1.49:8080/app/static/image/zfgs/zfgs2.jpg"],
            list:[]
        }
    },
	 async onShow() {
		
	},
	onLoad(e) {
	  if (typeof e.item !== "undefined") {
	    try {
	      this.itemContent = JSON.parse(e.item);
		  this.list =  this.itemContent.chlid
		  this.title = this.itemContent.title
	      console.log(this.itemContent,'this.itemContent===');
	    } catch (error) {
	      console.error("Failed to parse item:", error);
	    }
	  } else {
	    console.warn("Item is undefined.");
	  }
	},
	
    methods:{
		async refresherrefresh() {
			this.triggered = true
			this.query.pageNo = 1;
			await this.loadList()
			this.triggered = false
		},
		jmp(item){
			let obj={
				projectno:this.itemContent.projectno,
				projectname:this.itemContent.projectname,
				// chlid:item.chlid,
				title:item.name,
				id:item.id,
			}
			uni.navigateTo({
			  url: "/pages/zfgs/index/xmwj/list3?item=" + JSON.stringify(obj),
			});
		},
		loadList(type) {
			this.$u.api.zfgs.pmDesignchangeData(this.query).then(res => {
				if (res.list.length < 20 || res.list.length == 0) {
					this.loadStatus = "nomore";
				}
				var list = res.list;
				if (type == "add") {
					for (var i = 0; i < list.length; i++) {
						this.list.push(list[i])
					}
				} else {
					this.list = list;
				}
			})
		
		},
		loadMore() {
			this.loadStatus = "loading";
			setTimeout(() => {
				this.query.pageNo += 1;
				this.loadList("add");
			}, 100);
		},
		
        add(item){
            console.log(item,'item')
            if(item){
                uni.navigateTo({
                    url: '/pages/zfgs/proj/zg/pmRectification/form?id='+item.id
                })
            }else{
                uni.navigateTo({
                    url: '/pages/zfgs/proj/zg/pmRectification/form?projectno='+this.itemContent.projectno + '&name='+this.itemContent.projectname + "&id=''"
                })
            }
        },
        ViewImage(imageList,e) {
            // 阻止冒泡
            const url = imageList.map(item => item.url);
            e.stopPropagation();
            uni.previewImage({
                urls: url,
                current: e.currentTarget.dataset.url
            });
        },
    }
  }

</script>
<style lang="scss" scoped>
	/deep/ .u-progress.data-v-0d33af60 {
		display: none;
	}
	/deep/.u-input__input.data-v-460c1d26 {
	    text-align: right;
	}
.cu-btn {
  font-size: 16px;
  height: 40px;
}
.foot{
    background: #fff;
}
.cu-item{
  flex-wrap: wrap;
  padding: 15px !important;
}
.title{
    flex-shrink: 0;
}
.grid-square{
    margin-bottom: 0 !important;
}
::v-deep .u-input__input{
	text-align: right;
}
</style>